package cn.jwelll.bxcstock

import android.os.Bundle
import cn.jwelll.bxcstock.base.BaseActivity
import cn.jwelll.bxcstock.common.ConstValue
import cn.jwelll.bxcstock.common.mStartActivity
import cn.jwelll.bxcstock.ui.carin.preview.CarInPreviewActivity
import cn.jwelll.bxcstock.ui.dialog.DialogUtils
import cn.jwelll.bxcstock.ui.train.TrainInActivity
import cn.jwelll.bxcstock.util.ActivityUtil
import cn.jwelll.bxcstock.util.SPUtils
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : BaseActivity() {
    override fun getContentView() = R.layout.activity_main
    override fun getTitleString() = ""
    override fun initData() {
        super.initData()

    }

    override fun initView() {
        super.initView()
        tv_name.text="${ SPUtils.getString(this,ConstValue.USER_NAME,"")} ,欢迎使用提货系统库存管理！"
        tv_location.text=SPUtils.getString(this,ConstValue.WARE_HOUSE_NAME,"")
    }

    override fun initEvent() {
        super.initEvent()
        iv_carin.setOnClickListener {
            mStartActivity(CarInPreviewActivity::class.java)
        }
        iv_tranin.setOnClickListener {
            mStartActivity(TrainInActivity::class.java)
        }
        tv_quit.setOnClickListener {
            DialogUtils.Builder(this).setMessage("确定退出当前账号吗？")
                .setNegativeButton("取消", R.color.color_999999, null).setPositiveButton("确定", R.color.color_2d5aff) {
                    SPUtils.putBoolean(this, ConstValue.LOGIN_STATE, false)
                    SPUtils.putString(this, ConstValue.URL_TOKEN, "")
                    finish()
                    ActivityUtil.startLogin(this);
                }.creat().show()
        }
    }

    override fun onBackPressed() {
        moveTaskToBack(true)
    }
}
